package behavioral.Iterator.outer;

import behavioral.Iterator.IAggregate;
import behavioral.Iterator.IIterator;

public class CustomAggregate implements IAggregate {
    private Object[] arrSrc;

    public CustomAggregate(Object[] arrSrc) {
        this.arrSrc = arrSrc;
    }

    @Override
    public IIterator it() {
        return new CustomIterator(this);
    }

    public Object getElement(int i) {
        if (i > arrSrc.length - 1) {
            return null;
        }

        return arrSrc[i];
    }

    public int size() {
        return this.arrSrc.length;
    }
}
